
function replaceToLowerCase (letter) {
  if (!letter) { return letter }
  return letter.replace(/-([a-zA-Z])/g, function (match, needReplaceString) {
    return needReplaceString.toUpperCase()
  })
}

export default context => {
  const files = require.context('./modules', false, /\.js$/)
  const modules = {}

  files.keys().forEach(key => {
    modules[replaceToLowerCase(key.replace(/(\.\/|\.js)/g, ''))] = files(key).default(context)
  })
  return {
    namespaced: true,
    modules
  }
}
